import React from "react";
import PubSub from 'pubsub-js';

export default function HeroSearch() {
  let input = React.useRef();
  //声明函数
  let search = () => {
    //获取文本框的输入内容
    let v = input.current.value;
    //发布
    PubSub.publish('keyword', v)
  }
  return (
    <div className="text-right">
      <input type="text" ref={input} />
      <button onClick={search}>搜索</button>
    </div>
  );
}
